﻿using System;
using System.IO;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace PlatformerCS
{
    /// <summary>
    /// Animation that handles specificaly the player sprites.
    /// Possesses unique method for the character sprite sheet.
    /// </summary>
    class PlayerAnimation : Animation
    {
        // The entity is the player
        new Player entity;

        public PlayerAnimation(Player player, Animation.AnimInfo info)
            : base(player, info)
        {
            entity = player;
        }

        public override void Update()
        {
            timer++;
            //System.Diagnostics.Debug.WriteLine("" + current.X + " " + current.Y + " " + current.Width + " " + current.Height);
            //System.Diagnostics.Debug.WriteLine("" + timer);
            if (timer > rate)
            {

                angle = 0;
                // Iterate from left to right
                if (entity.Orientation == 1)
                    current.X = (current.X + 1) % maxSize.X;
                // Iterate right to left
                else
                {
                    angle = (float)(180 * 2 * Math.PI) / 360;
                    if (current.X == 0)
                        current.X = maxSize.X - 1;
                    else
                        current.X--;
                }

                timer = 0;
            }
        }
    }
}
